package com.example.zhujiemian;

import android.app.ActivityOptions;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;


public class RegisterActivity extends AppCompatActivity {

    private EditText mEdit1;
    private EditText mEdit2;
    private EditText mEdit3;
    private EditText mEdit4;
    private EditText mEdit5;
    private Button mButton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        mEdit1=findViewById(R.id.register_edit1);
        mEdit2=findViewById(R.id.register_edit2);
        mEdit3=findViewById(R.id.register_edit3);
        mEdit4=findViewById(R.id.register_edit4);
        mEdit5=findViewById(R.id.register_edit5);
        mButton=findViewById(R.id.register_button);

        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name = mEdit1.getText().toString();
                String grade=mEdit2.getText().toString();
                String username = mEdit4.getText().toString();
                String id=mEdit3.getText().toString();
                String password=mEdit5.getText().toString();

                Intent intent = new Intent();
                intent.putExtra("name", name);
                intent.putExtra("grade",grade);
                intent.putExtra("username",username);
                intent.putExtra("password",password);
                intent.putExtra("id",id);

                setResult(RESULT_OK, intent);
                onBackPressed();
            }
        });
        Button button2=(Button)findViewById(R.id.register_button);
        button2.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){

                AlertDialog alertDialog=new AlertDialog.Builder(RegisterActivity.this)
                        .setTitle("系统提示")
                        .setMessage("注册成功!")
                        .setNegativeButton("确定",new DialogInterface.OnClickListener(){
                            @Override
                            public void onClick(DialogInterface dialog,int which){
                             Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
                startActivity(intent, ActivityOptions.makeSceneTransitionAnimation
                        (RegisterActivity.this).toBundle());
                            }
                        })
                        .show();
            }
        });
    }
    private boolean allInputNotEmpty(String... inputStrings) {
        for (int i = 0; i < inputStrings.length; i++) {
            if (TextUtils.isEmpty(inputStrings[i])) {
                return false;
            }
        }
        return true;
    }

}
